package com.zim.ta_service.support;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

public class PasswordEncoderUtil {

	private static final PasswordEncoder ENCODER = new BCryptPasswordEncoder();

	/**
	 * 密码校验
	 * @param raw 原文
	 * @param encoded 密文
	 * @return true:密码正确
	 */
	public static Boolean matches(String raw, String encoded) {
		return new BCryptPasswordEncoder().matches(raw, encoded);
	}

	/**
	 * 密码加密
	 * @param raw 原文
	 * @return 密文
	 */
	public static String encode(String raw) {
		return new BCryptPasswordEncoder().encode(raw);
	}
}
